<template>
  <div id="discount">
    <div class="title">
      <ul>
        <li :class="{active: isShowQuan,act: isEmptyQuan}" @click="isSwitch(index=1)">优惠券
          <div class="xx"></div>
        </li>
        <li :class="{active: isShowKu,act: isEmptyKu}" @click="isSwitch(index=2)">弹药库
          <div class="xx"></div>
        </li>
      </ul>
    </div>
    <!-- 优惠券 -->
    <div class="content" v-if="isShowQuan">
      <div class="list">
        <div class="top">
          <img src="../../assets/taotao.png" alt="">
          <div class="text">
            <p>限杜蕾斯 避孕套 男用 安全套 超薄尊享三合一18只装</p>
            <div class="tt">
              <span class="money">￥</span>
              <b>20</b>
              <span class="man">满99可用</span>
            </div>
          </div>
        </div>
        <div class="time">有效期：2018-12-21 ~2018-02-21</div>
      </div>
      <div class="list">
        <div class="top">
          <img src="../../assets/taotao.png" alt="">
          <div class="text">
            <p>限杜蕾斯 避孕套 男用 安全套 超薄尊享三合一18只装</p>
            <div class="tt">
              <span class="money">￥</span>
              <b>20</b>
              <span class="man">满99可用</span>
            </div>
          </div>
        </div>
        <div class="time">有效期：2018-12-21 ~2018-02-21</div>
      </div>
      <div class="list">
        <div class="top">
          <img src="../../assets/taotao.png" alt="">
          <div class="text">
            <p>限杜蕾斯 避孕套 男用 安全套 超薄尊享三合一18只装</p>
            <div class="tt">
              <span class="money">￥</span>
              <b>20</b>
              <span class="man">满99可用</span>
            </div>
          </div>
        </div>
        <div class="time">有效期：2018-12-21 ~2018-02-21</div>
      </div>
      <!-- 底部 -->
      <div class="bottom"  @click="displayMotaiQuan">
        优惠隐私保护
      </div>
    </div>
    <!-- 空优惠券 -->
    <div class="quan" v-if="isEmptyQuan">
      <div class="empty">
        <div>
          <img src="../../assets/youhuijuankong.png" alt="">
          <p>暂无优惠券</p>
        </div>
      </div>
      <!-- 底部 -->
      <div class="bottom" @click="displayMotaiQuan">
        优惠隐私保护
      </div>
    </div>
    <!-- 弹药库 -->
    <div class="content danyao" v-if="isShowKu">
      <div class="list">
        <div class="top">
          <img src="../../assets/taotao.png" alt="">
          <div class="text">
            <p>限杜蕾斯 避孕套 男用 安全套 超薄尊享三合一18只装</p>
            <div class="tt">
              <b>兑换券</b>
            </div>
          </div>
        </div>
        <div class="time">有效期：2018-12-21 ~2018-02-21</div>
      </div>
      <div class="list">
        <div class="top">
          <img src="../../assets/taotao.png" alt="">
          <div class="text">
            <p>限杜蕾斯 避孕套 男用 安全套 超薄尊享三合一18只装</p>
            <div class="tt">
              <b>兑换券</b>
            </div>
          </div>
        </div>
        <div class="time">有效期：2018-12-21 ~2018-02-21</div>
      </div>
      <div class="list">
        <div class="top">
          <img src="../../assets/taotao.png" alt="">
          <div class="text">
            <p>限杜蕾斯 避孕套 男用 安全套 超薄尊享三合一18只装</p>
            <div class="tt">
              <b>兑换券</b>
            </div>
          </div>
        </div>
        <div class="time">有效期：2018-12-21 ~2018-02-21</div>
      </div>
      <!-- 底部 -->
      <div class="bottom" @click="displayMotaiKu">
        优惠隐私保护
      </div>
    </div>
    <!-- 空弹药库 -->
    <div class="quan ku" v-if="isEmptyKu">
      <div class="empty">
        <div>
          <img src="../../assets/danyaokukong.png" alt="">
          <p>没弹药啦~</p>
        </div>
      </div>
      <!-- 底部 -->
      <div class="bottom" @click="displayMotaiKu">
        优惠隐私保护
      </div>
    </div>
    <!-- 优惠券模态框 -->
    <div class="motai" v-if="isMotaiQuan" @click="hideMotaiQuan">
      <div
      :class="{model: true,animation: isModel}">
        <div class="title public">选择优惠券可见与不可见</div>
        <div class="public" @click="showQuan">可见</div>
        <div class="public" @click="hideQuan">不可见</div>
      </div>
    </div>
    <!-- 弹药库模态框 -->
    <div class="motai" v-if="isMotaiKu" @click="hideMotaiKu">
      <div
      :class="{model: true,animation: isModel}">
        <div class="title public">选择弹药库可见与不可见</div>
        <div class="public" @click="showKu">可见</div>
        <div class="public" @click="hideKu">不可见</div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: 'Discount',
  data () {
    return {
      isShowQuan: true,
      isShowKu: false,
      isMotaiQuan: false,
      isMotaiKu: false,
      isModel: false,
      isEmptyQuan: false,
      isEmptyKu: false
    }
  },
  created () {
    document.title = '我的优惠'
  },
  methods: {
    isSwitch (id) {
      if (id === 1) {
        if (this.isEmptyQuan) {
          this.isShowQuan = false
          this.isShowKu = false
          this.isEmptyKu = false
        } else {
          this.isShowQuan = true
          this.isEmptyQuan = false
          this.isShowKu = false
          this.isEmptyKu = false
        }
      } else if (id === 2) {
        if (this.isEmptyKu) {
          this.isShowKu = false
          this.isShowQuan = false
          this.isEmptyQuan = false
        } else {
          this.isShowQuan = false
          this.isEmptyQuan = false
          this.isShowKu = true
          this.isEmptyKu = false
        }
      }
    },
    // 优惠券函数
    displayMotaiQuan () {
      this.isMotaiQuan = true
      if (this.isMotaiQuan) {
        this.isModel = true
      }
    },
    hideMotaiQuan () {
      this.isMotaiQuan = false
    },
    showQuan () {
      this.isShowQuan = true
      this.isEmptyQuan = false
    },
    hideQuan () {
      this.isShowQuan = false
      this.isEmptyQuan = true
    },
    // 弹药库函数
    displayMotaiKu () {
      this.isMotaiKu = true
      if (this.isMotaiKu) {
        this.isModel = true
      }
    },
    hideMotaiKu () {
      this.isMotaiKu = false
    },
    showKu () {
      this.isShowKu = true
      this.isEmptyKu = false
    },
    hideKu () {
      this.isShowKu = false
      this.isEmptyKu = true
    }
  }
}
</script>

<style lang='scss' scoped>
#discount{
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  .title{
    height: 13.06vw;
    background-color: #fff;
    box-shadow:0px 1.2vw 2.8vw 0px rgba(0,0,0,0.06);
    z-index: 222;
    ul{
      display: flex;
      justify-content: space-between;
      height: 98%;
      li{
        width: 49%;
        height: 13.06vw;
        text-align: center;
        line-height: 13.06vw;
        font-size: 4.53vw;
        font-family: SourceHanSansCN-Regular;
        font-weight: 400;
        color: rgba(22,22,22,1);
        &.active{
          font-size: 4.53vw;
          font-family:SourceHanSansCN-Bold;
          font-weight:bold;
          color:rgba(22,22,22,1);
          position: relative;
          .xx{
            width: 7.46vw;
            height: 0.8vw;
            background-color: #0A6DFF;
            position: absolute;
            bottom: 1.5vw;
            left: 21vw;
          }
        }
        &.act{
          font-size: 4.53vw;
          font-family:SourceHanSansCN-Bold;
          font-weight:bold;
          color:rgba(22,22,22,1);
          position: relative;
          .xx{
            width: 7.46vw;
            height: 0.8vw;
            background-color: #0A6DFF;
            position: absolute;
            bottom: 1.5vw;
            left: 21vw;
          }
        }
      }
    }
  }
  .content{
    flex: 1;
    background-color: #4112E7;
    // padding: 4vw 3.46vw 0 3.46vw;
    display: flex;
    flex-direction: column;
    align-items: center;
    &.danyao{
      background-color: #E7127E;
    }
    .list{
      width: 93.06vw;
      height: 41.86vw;
      background: url('../../assets/wdeyouhuijuanbj.png') no-repeat center;
      background-size: 100% 100%;
      padding: 4vw;
      margin-top: 4vw;
      box-sizing: border-box;
      .top{
        display: flex;
        img{
          width: 20vw;
          height: 20vw;
          margin-right: 1vw;
        }
        .text{
          p{
            font-size: 4vw;
            font-family:SourceHanSansCN-Bold;
            font-weight:bold;
            color:rgba(22,22,22,1);
            line-height: 5.33vw;
            margin-bottom: 4vw;
          }
          .tt{
            .money{
              font-size: 4.26vw;
              font-family:SourceHanSansCN-Bold;
              font-weight:bold;
              color:rgba(255,0,0,1);
              margin-right: -1vw;
            }
            b{
              font-size: 5.6vw;
              font-family:SourceHanSansCN-Bold;
              font-weight:bold;
              color:rgba(255,0,0,1);
              margin-right: 2.66vw;
            }
            .man{
              font-size: 3.2vw;
              font-family:SourceHanSansCN-Regular;
              font-weight:400;
              color:rgba(255,0,0,1);
            }
          }
        }
      }
      .time{
        font-size: 2.93vw;
        font-family:SourceHanSansCN-Regular;
        font-weight:400;
        color:rgba(255,0,0,1);
        margin-top: 10vw;
      }
    }
    .bottom{
      width: 100%;
      height: 13.86vw;
      text-align: center;
      line-height: 13.86vw;
      position: fixed;
      bottom: 0;
      font-size: 3.2vw;
      font-family: SourceHanSansCN-Regular;
      font-weight: 400;
      color: rgba(255,255,255,0.6);
    }
  }
  .quan{
    flex: 1;
    background-color: #4112E7;
    display: flex;
    flex-direction: column;
    align-items: center;
    &.ku{
      background-color: #E7127E;
    }
    .empty{
      width: 78.66vw;
      height: 111.46vw;
      background-color: #fff;
      display: flex;
      justify-content: center;
      align-items: center;
      border-radius:0px 0px 1vw 1vw;
      div{
        display: flex;
        flex-direction: column;
        align-items: center;
        img{
          width: 24.66vw;
          height: 30.66vw;
        }
        p{
          font-size: 3.73vw;
          font-family: SourceHanSansCN-Regular;
          font-weight: 400;
          color: rgba(134,134,134,1);
        }
      }
    }
    .bottom{
      width: 100%;
      height: 13.86vw;
      text-align: center;
      line-height: 13.86vw;
      position: fixed;
      bottom: 0;
      font-size: 3.2vw;
      font-family: SourceHanSansCN-Regular;
      font-weight: 400;
      color: rgba(255,255,255,0.6);
    }
  }
  .motai{
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    position: absolute;
    z-index: 250;
    .model{
      width: 100%;
      height: 0;
      // height: 44vw;
      background-color: #fff;
      position: fixed;
      bottom: 0;
      border-radius: 2.13vw 2.13vw 0px 0px;
      &.animation{
        height: 44vw;
        transition: height 3s;
      }
      .public{
        height: 14.66vw;
        line-height: 14.66vw;
        padding: 0 3.46vw;
        &.title{
          font-size: 3.73vw;
          font-family: SourceHanSansCN-Regular;
          font-weight: 400;
          color: rgba(134,134,134,1);
      }
      }
    }
  }
}
</style>
